/**
 * Created by pactera on 16/12/28.
 */
/**
 * Created by Brant on 2016/12/28.
 */
module.exports = function ($http,$location,$state,httpservice) {
    var findpasswordService = {};
    findpasswordService.phoneVerify = function (phoneNum,phoneCode) {
        // 手机验证
        var params={"cellphone":phoneNum,"code":phoneCode};

        return $http(
            {
                url : httpservice.findpasswordUrl,
                method : 'POST',
                data : params,
                dataType : 'json',
                headers : {'Content-Type':'application/json'}
            }
        )
            .then(function (response) {
                return response.data;
            })
            .catch(function (response) {
                console.error('phoneVerify error', response.status, response.data);
            })
            .finally(function () {
                /*$("#errormsgId").html("网络链接失败！");*/
            });
    };

    findpasswordService.emailVerify = function (emailNum,picCode) {
        // 邮箱验证
        var params={"email":emailNum,"picCode":picCode};
        return $http(
            {
                url : httpservice.findpasswordUrl,
                method : 'POST',
                data : params,
                dataType : 'json',
                headers : {'Content-Type':'application/json'}
            }
        )
            .then(function (response) {
                return response.data;
            })
            .catch(function (response) {
                console.error('emailVerify error', response.status, response.data);
            })
            .finally(function () {
                /*$("#errormsgId").html("网络链接失败！");*/
            });
    };
    //手机找回验证码
    findpasswordService.sendMesCod = function (phoneNum,mode,picCode) {
        var  params ={"cellphone":phoneNum,"mode":mode,"picCode":picCode};
        return $http({
                url : httpservice.getVerifyCodeUrl,
                method : 'POST',
                data : params,
                dataType : 'json',
                headers : {'Content-Type':'application/json'}
            })
            .then(function (response) {
                return response.data;
            })
            .catch(function (response) {
                console.error('getVerifyCode error', response.status, response.data);
            })
            .finally(function () {

            });
    };

    return findpasswordService;
};
